const express = require('express');
const app = express();
app.listen(9000, () => {
  console.log('服务器9000启动成功');
});

// 注册解析POST请求体URL-Encoded格式数据的中间件
app.use(express.urlencoded());

// 访问地址 http://localhost:9000/middleware_urlencoded (注意添加请求体)
app.post('/middleware_urlencoded', (req, res) => {
  console.log('客户端发送POST请求');
  console.log('body', req.body); // body { body_name: 'body' }
  res.end();
});